package com.课上案例练习.线程.线程操作.join方法的验证;

/**
 * 说明了 join方法，表示的是join将调用的线程进入阻塞状态，等到目标线程执行完，才会去执行
 */
public class Test2 {
    public static void main(String[] args) {
        Thread threadA = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName());

            }
        }, "线程A");
        Thread threadB = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName());
                try {
                    threadA.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "线程B");
        Thread threadC = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName());
            }
        }, "线程C");
        threadC.start();
        threadB.start();
        threadA.start();

    }


}
